package com.leyou.auth.config;

import com.leyou.common.auth.utils.RsaUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.annotation.PostConstruct;
import java.security.PrivateKey;
import java.security.PublicKey;

@Data
@ConfigurationProperties("ly.jwt")
public class JwtProperties {
    private String pubKeyPath;
    private String priKeyPath;

    private PrivateKey privateKey;
    private PublicKey publicKey;

    /**
     * <bean id="" class="" init-method="" destroy-method=""
     */
    @PostConstruct
    public void init() throws Exception {
        privateKey = RsaUtils.getPrivateKey(priKeyPath);
        publicKey = RsaUtils.getPublicKey(pubKeyPath);
    }

    private CookiePojo cookie = new CookiePojo();

    @Data
    public class CookiePojo{
        private Integer expire;
        private Integer refreshTime;
        private String cookieName;
        private String cookieDomain;
    }

    private AppTokenPojo app = new AppTokenPojo();

    @Data
    public class AppTokenPojo{
        private Integer expire;
        private Long id;
        private String serviceName;
    }

}
